﻿using System;
using System.Collections.Generic;
using System.Text;


using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
using OT.Module.ModelConst;
using OT.Common;
using OT.EntLib.Validate;

namespace OT.Module.Model
{
    [OptimisticLocking(false)]
    [Persistent(GDB.Product)]
    public partial class Product : XPLiteObject
    {
        #region ~

        /// <summary>
        /// 构造函数
        /// </summary>
        public Product() : base ( new Session() )
        {

        }

        public Product(Session s)
            : base(s)
        {
        }

        public Product(Session s, XPClassInfo info)
            : base(s, info)
        {
        }

        #endregion

        #region ID

        private string _ID = "";
        /// <summary>
        /// 
        /// </summary>
        /// 
        [Key(false)]
        public string ID
        {
            get
            {
                return _ID;
            }
            set
            {
                _ID = value;
            }
        }
        #endregion
                
        #region Name 产品名称
        
        private string _Name = "";

        [StringLengthValidator(GConst.NameMinLen, GConst.NameMaxLen,
          MessageTemplate = MsgUtility.StringLength, Tag = GSyntax.Product.Name)]
        [DisplayName(GSyntax.Product.Name), Size(GConst.NameMaxLen)]
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                SetPropertyValue("Name", ref _Name, value);
            }
        }

        #endregion

        #region Price 零售价格

        private decimal _Price = 0M;
        [RangeValidator(0d, RangeBoundaryType.Exclusive, (double)Decimal.MaxValue, RangeBoundaryType.Exclusive,
               MessageTemplate = MsgUtility.GreaterZero, Tag = GSyntax.Product.Price)]
        [DisplayName(GSyntax.Product.Price)]
        public decimal Price
        {
            get { return _Price; }
            set { _Price = value; }
        }

        #endregion

        #region StoreTime 入库日期

        private DateTime _StoreTime = DateTime.MinValue;

        [RangeValidator(GConst.DateMin, RangeBoundaryType.Inclusive, GConst.DateMax, RangeBoundaryType.Inclusive,
           MessageTemplate = MsgUtility.DateTimeRange, Tag = GSyntax.Product.StoreTime)]
        [DisplayName(GSyntax.Product.StoreTime)]
        public DateTime StoreTime
        {
            get { return _StoreTime; }
            set { _StoreTime = value; }
        }

        #endregion

        #region DivValue 区间值

        private int _DivValue = 0;

        [DisplayName(GSyntax.Product.DivValue)]
        public int DivValue
        {
            get { return _DivValue; }
            set { _DivValue = value; }
        }

        #endregion

        #region Stamp

        private byte[] _Stamp;

        [NonPersistent]
        public byte[] Stamp
        {
            get
            {
                return _Stamp;
            }
            set
            {
                _Stamp = value;
            }
        }

        #endregion
    }
}
